﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using YXChatApiService.Core.AccountEntity;

namespace YXChatApiService.Core.Common.Seed
{
    public class InitDbDataBuilder
    {
        private readonly YxChatDbContext _context;

        public InitDbDataBuilder(YxChatDbContext context)
        {
            _context = context;
        }
        public void Create()
        {
            #region Account
            var entity = _context.Account.FirstOrDefault(n=>n.AccountNumber=="admin");
            if (entity==null)
            {
                entity = new Account
                {
                    AccountNumber = "admin",
                    PassWord = "admin",
                    NickName = "admin",
                    Signature = "admin is admin",
                    Id = Guid.NewGuid()
                };
                _context.Account.Add(entity);
                _context.SaveChanges();
            }
            #endregion
        }
    }
}
